from django.contrib import admin

from app.admin import SimpleModelAdmin
from vip.models import *


@admin.register(VipLevel)
class VipLevelAdmin(SimpleModelAdmin):
    list_display = ['pk', 'level_code', 'level_name', 'desc']
    list_display_links = ['pk', 'level_code']
    search_fields = ['level_code', 'level_name', 'desc']


@admin.register(VipSales)
class VipSalesAdmin(SimpleModelAdmin):
    list_display = [
        'pk', 'vip_level', 'amount_initial', 'amount_left', 'total_payed_amount',
        'vip_dates', 'price_show', 'sales_start', 'sales_end', 'is_show']
    list_display_links = ['pk', 'vip_level']
    autocomplete_fields = ['vip_level']
    search_fields = ['id', 'vip_level__level_name']
    list_filter = ['is_show']
    list_editable = ['is_show']


@admin.register(VipSalesOrder)
class VipSalesOrderAdmin(SimpleModelAdmin):
    list_display = [
        'pk', 'order_number', 'user', 'vip_sales', 'price_initial', 'price_payed', 'is_payed', 'amount_used']
    list_display_links = ['pk', 'order_number']
    autocomplete_fields = ['vip_sales', 'user']
    list_filter = ['is_payed', 'vip_sales']
    search_fields = ['order_number', 'id', 'user__nick_name', 'user__mobile']


@admin.register(UserInvite)
class UserInviteAdmin(SimpleModelAdmin):
    # readonly_fields = ['user', 'invited_user']
    list_display = ['pk', 'user', 'invited_user', 'datetime_created', 'datetime_updated']
    list_display_links = ['pk', 'user']
    search_fields = ['user', 'invited_user', 'user__mobile', 'invited_user__mobile']
